package com.hollycrm.hollysqm.analyzer.ansj;

import org.apache.lucene.analysis.Analyzer;

import java.util.Set;

public class AnsjAnalysis extends Analyzer {
	boolean pstemming;
	public Set<String> filter;
	boolean isQuery = true;

	/**
	 * @param filter
	 *            停用词
	 * @param pstemming
	 *            是否分析词干
	 */
	public AnsjAnalysis(Set<String> filter, boolean pstemming, boolean isQuery) {
		// System.out.println("AnsjAnalysis::AnsjAnalysis");
		this.filter = filter;
		this.pstemming = pstemming;
		this.isQuery = isQuery;
	}

	/**
	 * @param isQuery
	 *            是否分析词干.进行单复数,时态的转换
	 *
	 *            public AnsjAnalysis(boolean pstemming) { this.pstemming =
	 *            pstemming; }
	 */

	public AnsjAnalysis(boolean isQuery) {
		this.isQuery = isQuery;
	}

	public AnsjAnalysis() {
		super();
        System.out.println("analyzer init");
	}

	@Override
	public TokenStreamComponents createComponents(String fieldName) {
		//System.out.println("AnsjAnalysis::createComponents");
		return new TokenStreamComponents(new AnsjTokenizer(isQuery, filter,
				pstemming));
	}
}
